package com.code.springbootmybatis.controller;

import com.code.springbootmybatis.model.User;
import com.code.springbootmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: liyufei
 * @date: 2018-04-30 1:30
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/get/{username}")
    public User get(@PathVariable String username) {
        User user = userService.getByUsername(username);
        return user;
    }

    @PostMapping("/insert")
    public void insert(@RequestBody User user) {
        userService.insertUser(user);
    }
}
